#include <iostream>
#include <string>
#include <vector>
#include <set>
using namespace std;
class Solution
{
private:
    string local;
    string domain;
    string address;
    size_t index = string::npos;
    set<string> addresses;

public:
    int numUniqueEmails(vector<string> &emails)
    {
        for (string email : emails)
        {
            // splite local & domain
            local = email.substr(0, email.find_last_of('@'));
            domain = email.substr(email.find_last_of('@'));

            // process local
            local = local.substr(0, email.find_first_of('+'));

            while ((index = local.find_first_of('.')) != string::npos)
            {
                local = local.replace(index, 1, "");
            }

            address = local + domain;
            if (addresses.find(address) == addresses.end())
            {
                //cout << address << endl;
                addresses.insert(address);
            }
        }

        return addresses.size();
    }
};

int main(){
    return 0;
}